var express = require('express');
var router = express.Router();
<<<<<<< HEAD
const {getAllCarsInfor2,getCheckingCars2,getOneCar2,changeState2,addCarInfor2,getUserCar2} = require("../service/carsService")
=======
const {getAllCarsInfor2,getCheckingCars2,getOneCar2,changeState2,addCarInfor2,searchCars2} = require("../service/carsService")
>>>>>>> 3a6e1c5b2a92b6b41fa93099d5712e182c832949

/* 获取所有车辆信息*/
router.get('/allCarsInfor', async function(req, res, next) {
  const reqData = req.query
    const data= await getAllCarsInfor2(reqData)
    res.send(data);
  });
  // 分类获取车辆信息
router.get('/checkingCars', async function(req, res, next) {
  const reqData = req.query
    const data= await getCheckingCars2(reqData)
    res.send(data);
  });
  // 获取某一车
router.get('/getOneCar', async function(req, res, next) {
  const reqData = req.query
    const data= await getOneCar2(reqData)
    res.send(data);
  });

  //获取某一用户的车
router.get('/ownerid',async(req,res,next)=>{
  res.send(await getUserCar2(req.query));
  console.log(req.query);
})

  // 修改车辆状态
router.post('/changeState', async function(req, res, next) {
  const reqData = req.body
    const data= await changeState2(reqData)
    res.send(data);
  });
  // 增加车辆信息
router.put('/addCarInfor', async function(req, res, next) {
  const reqData = req.body
    const data= await addCarInfor2(reqData)
    res.send(data);
  });
  // 查找某一类车辆信息
router.get('/searchCars', async function(req, res, next) {
  const reqData = req.query
    const data= await searchCars2(reqData)
    res.send(data);
  });
  
  module.exports = router;